package com.ruoyi.cqjd.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cqjd.mapper.CqjdAddressBookMapper;
import com.ruoyi.cqjd.domain.CqjdAddressBook;
import com.ruoyi.cqjd.service.ICqjdAddressBookService;

/**
 * 地址管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-06-19
 */
@Service
public class CqjdAddressBookServiceImpl implements ICqjdAddressBookService 
{
    @Autowired
    private CqjdAddressBookMapper cqjdAddressBookMapper;

    /**
     * 查询地址管理
     * 
     * @param id 地址管理主键
     * @return 地址管理
     */
    @Override
    public CqjdAddressBook selectCqjdAddressBookById(Long id)
    {
        return cqjdAddressBookMapper.selectCqjdAddressBookById(id);
    }

    /**
     * 查询地址管理列表
     * 
     * @param cqjdAddressBook 地址管理
     * @return 地址管理
     */
    @Override
    public List<CqjdAddressBook> selectCqjdAddressBookList(CqjdAddressBook cqjdAddressBook)
    {
        return cqjdAddressBookMapper.selectCqjdAddressBookList(cqjdAddressBook);
    }

    /**
     * 新增地址管理
     * 
     * @param cqjdAddressBook 地址管理
     * @return 结果
     */
    @Override
    public int insertCqjdAddressBook(CqjdAddressBook cqjdAddressBook)
    {
        cqjdAddressBook.setCreateTime(DateUtils.getNowDate());
        return cqjdAddressBookMapper.insertCqjdAddressBook(cqjdAddressBook);
    }

    /**
     * 修改地址管理
     * 
     * @param cqjdAddressBook 地址管理
     * @return 结果
     */
    @Override
    public int updateCqjdAddressBook(CqjdAddressBook cqjdAddressBook)
    {
        cqjdAddressBook.setUpdateTime(DateUtils.getNowDate());
        return cqjdAddressBookMapper.updateCqjdAddressBook(cqjdAddressBook);
    }

    /**
     * 批量删除地址管理
     * 
     * @param ids 需要删除的地址管理主键
     * @return 结果
     */
    @Override
    public int deleteCqjdAddressBookByIds(Long[] ids)
    {
        return cqjdAddressBookMapper.deleteCqjdAddressBookByIds(ids);
    }

    /**
     * 删除地址管理信息
     * 
     * @param id 地址管理主键
     * @return 结果
     */
    @Override
    public int deleteCqjdAddressBookById(Long id)
    {
        return cqjdAddressBookMapper.deleteCqjdAddressBookById(id);
    }

    @Override
    public CqjdAddressBook getDefaultAddressByUserId(Long userId) {
        return cqjdAddressBookMapper.getDefaultAddressByUserId(userId);
    }

    @Override
    public List<CqjdAddressBook> getAddressListByUserId(Long userId) {

        return cqjdAddressBookMapper.getAddressListByUserId(userId);

    }

    @Override
    public void updateAddressBookByUserId(CqjdAddressBook addressBook) {
         cqjdAddressBookMapper.updateAddressBookByUserId(addressBook);

    }

    @Override
    public void updateAddressBookDefaultIsOffByUserId(Long userId) {
        cqjdAddressBookMapper.updateAddressBookDefaultIsOffByUserId(userId);

    }
}
